﻿@namespace Microsoft.FluentUI.AspNetCore.Components
@inherits FluentComponentBase

@if (DrawMenuWithoutService)
{
    <CascadingValue Value="this" IsFixed="true">
        @if (Open)
        {
            @if (Anchored)
            {
                <FluentOverlay @bind-Visible="@Open" OnClose="@CloseAsync" Transparent="true" FullScreen="true" />
                <FluentAnchoredRegion Anchor="@Anchor"
                                      HorizontalDefaultPosition="@HorizontalPosition"
                                      HorizontalInset="@HorizontalInset"
                                      HorizontalScaling="@HorizontalScaling"
                                      HorizontalThreshold="@HorizontalThreshold"
                                      HorizontalViewportLock="@HorizontalViewportLock"
                                      VerticalDefaultPosition="@VerticalPosition"
                                      VerticalInset="@VerticalInset"
                                      VerticalThreshold="@VerticalThreshold"
                                      Shadow="@ElevationShadow.None"
                                      Class="@ClassValue"
                                      Style="@StyleValue"
                                      @attributes="AdditionalAttributes">
                    <fluent-menu @ref=Element id="@Id">
                        @ChildContent
                    </fluent-menu>
                </FluentAnchoredRegion>
            }
            else
            {
                if (_contextMenu)
                {
                    <FluentOverlay @bind-Visible="@Open" OnClose="@CloseAsync" Transparent="true" FullScreen="true" />
                }
                <fluent-menu @ref=Element
                             id="@Id"
                             class="@ClassValue"
                             style="@StyleValue"
                             @attributes="AdditionalAttributes">
                    @ChildContent
                </fluent-menu>
            }
        }
    </CascadingValue>
}
